Skip to content

BlockCovariance: block-wise precision_ (fix O(p^3) densify) - #54

Merged
microprediction merged 1 commit into
mainfrom
block-covariance-precision
Jun 11, 2026
Merged

BlockCovariance: block-wise precision_ (fix O(p^3) densify)#54
microprediction merged 1 commit into
mainfrom
block-covariance-precision

Conversation

@microprediction

Copy link
Copy Markdown
Owner

Fixes the code review finding on BlockCovariance: the inherited base precision_ densified the full p×p covariance and inverted it globally (O(p³), O(p²) memory), defeating the estimator's whole memory/compute thesis and contradicting its docstring ("the precision is likewise block-wise").

  • Override precision_ to invert each small block and assemble block-diagonally — O(p·b²), PD by construction, never forms or inverts the dense matrix.
  • Factor the shared per-block PD construction into _pd_block (used by both covariance_ and precision_).
  • Test: precision_ is block-diagonal, positive-definite, and a genuine inverse (P @ C = I).

ruff ✓, mypy ✓, full suite 218 passed.

🤖 Generated with Claude Code

…e O(p^3) inverse

The inherited base precision_ densified the full p x p covariance and inverted it globally,
defeating the estimator's memory/compute thesis (and contradicting its own docstring). Override
precision_ to invert each small block and assemble block-diagonally -- positive-definite by
construction, never forming or inverting the dense matrix. Factor the shared per-block PD
construction into _pd_block. Add a test: precision_ is block-diagonal, PD, and a genuine inverse
of the covariance (P @ C = I).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@microprediction
microprediction merged commit 97c150d into main Jun 11, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant